package com.cq.hd.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cq.hd.common.enums.biz.OrderSettleBillTradeTypeEnum;
import com.cq.hd.order.mapper.TbOrderSettleBillItemMapper;
import com.cq.hd.order.po.TbOrderSettleBillItemPo;
import com.cq.hd.order.service.TbOrderSettleBillItemService;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author much
 * @since 2024/04/11 22:13
 */
@Service
public class TbOrderSettleBillItemServiceImpl extends ServiceImpl<TbOrderSettleBillItemMapper, TbOrderSettleBillItemPo>
        implements TbOrderSettleBillItemService {

    @Override
    public List<TbOrderSettleBillItemPo> listSubsidyBillItemByOrderIds(List<Long> orderIds) {
        if (CollectionUtils.isEmpty(orderIds)) {
            return Collections.emptyList();
        }
        LambdaQueryWrapper<TbOrderSettleBillItemPo> qw = Wrappers.<TbOrderSettleBillItemPo>lambdaQuery()
                .in(TbOrderSettleBillItemPo::getOrderId, orderIds)
                .eq(TbOrderSettleBillItemPo::getTradeType, OrderSettleBillTradeTypeEnum.SUBSIDY_AMT.getValue());
        return list(qw);
    }

    @Override
    public List<TbOrderSettleBillItemPo> listByBillIds(List<Long> billIds) {
        if (CollectionUtils.isEmpty(billIds)) {
            return Collections.emptyList();
        }
        LambdaQueryWrapper<TbOrderSettleBillItemPo> qw = Wrappers.<TbOrderSettleBillItemPo>lambdaQuery()
                .in(TbOrderSettleBillItemPo::getBillId, billIds);
        return list(qw);
    }

}
